package com.atguigu.amqp.service;

import com.atguigu.amqp.bean.Book;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Service;

/**
 * @Description TODO
 * @Author zouxiang
 * @Date 2020/4/3/19:55
 */
@Service
@Slf4j
public class BookService {
    /**
     * 监听 atguigu.news 队列的消息
     * @param book
     */
    @RabbitListener(queues = "atguigu.news")
    public void receive(Book book){
       log.info("收到消息" + book.toString());
    }

    /**
     * 获得消息头
     * @param message
     */
    @RabbitListener(queues = "atguigu")
    public void receive2(Message message){
        log.info(String.valueOf(message.getBody()));
        log.info(String.valueOf(message.getMessageProperties()));
    }
}
